/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package modeles.beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import utilitaires.cryptographie.Sha512;

/**
 *
 * @author Fred
 */
@ManagedBean
@SessionScoped
public class LoginBean {

    private boolean loggedIn;
    private final String LOGIN;
    private final String MDP;      

    /**
     * Creates a new instance of SessionBean
     */
    public LoginBean() {
        this.LOGIN = "admin";
        this.MDP = "2de42c5eab64f95bb6723be923f083b371c86f188b6dcf1df1393fd89a505f4ac1943971ba0ed6c2f0569a74c949ac25cff933de49fe8a1521eb3f45ef18d9bb";
    }

    public boolean isLoggedIn() {
        return loggedIn;
    }

    public void setLoggedIn(Boolean loggedIn) {
        this.loggedIn = loggedIn;
    }      

    public boolean login(String login, String mdp) {
        loggedIn = login.equals(LOGIN) && Sha512.comparer(MDP, mdp);
        return loggedIn;
    }
}
